const request = function(url, data) {
	uni.showLoading({
		title: "请稍后..."
	})
	return new Promise((resolve, reject) => {
		uni.request({
			method: "POST",
			url: `https://logistics.yingmin.top/${url}`,
			data,
			header: {},
			success: (res) => {
				if (res.data.code !== '200') {
					uni.showModal({
						content: res.data.msg,
						showCancel: false,
						confirmText: "我知道了",
						success() {
							reject()
						},
						fail() {
							reject()
						}
					})
					return
				}
				resolve(res)
			},
			fail: (err) => {
				reject(err)
			},
			complete: () => {
				uni.hideLoading();
			}
		});
	})
}

export default request
